package com.zftlive.android.sample.scrollview;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.zftlive.android.R;
import com.zftlive.android.library.base.BaseMAdapter;

/**
 * 众筹产品信息列表适配器
 * 
 * @author 曾繁添
 * @version 1.0
 * 
 */
public class ProductListAdapter extends BaseMAdapter {

	public ProductListAdapter(Activity mContext){
		super(mContext);
	}
	
	public int getCount() {
		return 10;
	}
	
	@Override
	public View getView(final int position, View itemView, ViewGroup parent) {
		
		// 查找控件
		ViewHolder holder = null;
		if(null == itemView){
			itemView = LayoutInflater.from(getActivity()).inflate(R.layout.activity_zc_project_product_list_item, null);
			holder = new ViewHolder();
			holder.tv_leave_number = (TextView) itemView.findViewById(R.id.tv_leave_number);
			holder.tv_support_number = (TextView) itemView.findViewById(R.id.tv_support_number);
			//缓存View
			itemView.setTag(holder);
		}else {
			holder = (ViewHolder) itemView.getTag();
		}
		
		//装填数据
		//TODO 剩余数额
		holder.tv_leave_number.setText(10+"");
		//TODO 支持数量
		holder.tv_support_number.setText(5000+"");
		
		
		return itemView;
	}

	class ViewHolder {
		TextView tv_product_name,
				tv_dispatch_cost_value, tv_repay_send_dt_value,
				tv_leave_number, tv_support_number;
	}
}
